package net.xiduth.game.player.dialogues.tutorial;

import net.xiduth.game.player.dialogues.Dialogue;

/**
 * 
 * Tutorial after helping the cook.
 *
 */

public class SkillsInstructor extends Dialogue {

	@Override
	public void start() {
	if (!player.isSkillsTutorial()) {
			sendNPCDialogue(7888, 9827,
					"Hey "+player.getDisplayName()+".");
		} else {
			sendNPCDialogue(7888, 9827,
					"Welcome back. Are you finished?");
		}	
	}

	@Override
	public void run(int interfaceId, int componentId) {
		switch (stage) {
		case -1:
			if (!player.isSkillsTutorial()){
				stage = 0;
				sendPlayerDialogue(9827, "Do you need something?");
			} else {
				stage = 11;
				sendPlayerDialogue(9827, "Yeah, take these.");
			}
			break;
		case 0:
			sendNPCDialogue(7888, 9827, "I need you to go on a quest. "+"You will have to overcome many fears and challenges.");
			stage = 1;
			break;
		case 1:
			sendNPCDialogue(7888, 9827, "Are you up for it, "+player.getDisplayName()+"?");
			stage = 2;
			break;
		case 2:
		sendOptionsDialogue(SEND_DEFAULT_OPTIONS_TITLE,
					"Yes, I have no fears!", "Explain more.",
					"Sorry, I'm busy right now.");
		case 3:
		switch (componentId) {
			case OPTION_1:
				sendPlayerDialogue(9827,
						"I have no fears, bring it on!");
				stage = 4;
				break;
			case OPTION_2:
				sendPlayerDialogue(9827,
						"What kind of fears are you talking about?");
				stage = 5;
				break;
			case OPTION_3:
				stage = 69;
				sendPlayerDialogue(9827,
						"Sorry I'm busy right now.");
				break;
			}
			break;
		case 4:
			sendNPCDialogue(7888, 9827, "That's more like it!");
				stage = 6;
				break;
		case 5:
			sendNPCDialogue(7888, 9827, "Let's see, death, drowning, choking, rotting...");
				stage = 7;
				break;
		case 6:
			sendNPCDialogue(7888, 9827, "I was joking, silly. I'm here to teach you the fundamentals of survival.");
			stage = 8;
			break;
		case 7:
			sendPlayerDialogue(9827, "Sounds fun...");
			stage = 2;
			break;
		case 8:
			sendNPCDialogue(7888, 9827, "Take this hatchet and bring me some logs from trees, "+ "east of here.");
			player.lock();
			player.getInventory().addItem(1351, 1);
			player.getBank().addItem(1351, 1, true);
			stage = 9;
			break;
		case 9:
			sendNPCDialogue(7888, 9827, "Next, "+"use this Tinderbox to light some logs, bring me the ashes.");
			player.getInventory().addItem(590, 1);
			player.getBank().addItem(590, 1, true);
			stage = 10;
			break;
		case 10:
			sendNPCDialogue(7888, 9827, "Finally, make bronze bars. With those, make me a bronze dagger!");
			player.getInventory().addItem(2347, 1);
			player.getInventory().addItem(437, 30); //copper
			player.getInventory().addItem(439, 30); //tin
			player.getBank().addItem(2347, 30, true);
			player.getBank().addItem(436, 30, true);
			player.getBank().addItem(438, 30, true);
			player.setSkillsTutorial();
			player.unlock();
			stage = 70;
			break;
		case 11:
			if (player.getInventory().containsItem(592, 1)
				&& player.getInventory().containsItem(1511, 1)
				&& player.getInventory().containsItem(1205, 1)) {
			sendNPCDialogue(7888, 9827,
			"Thanks, "+player.getDisplayName()+"!");
			stage = 12;
			} else { 
			sendNPCDialogue(7888, 9827,
					"You don't have the required items. "+"Get back to work!");
			player.getPackets().sendGameMessage("Remember, " + player.getDisplayName() + ". You will need... <col=C12006>ashes</col>, a <col=C12006>Bronze dagger</col>, and <col=C12006>logs</col>.");
			stage = 69;
			}
			break;		
		case 12:
			player.getInventory().deleteItem(592, 1);
			player.getInventory().deleteItem(1511, 1);
			player.getInventory().deleteItem(1205, 1);
				sendNPCDialogue(7888, 9827, "Impressive...");
					stage = 13;
					break;
		case 13:
			sendNPCDialogue(7888, 9827, "How did you manage to do that so fast?");
				stage = 14;
				break;
		case 14:
			sendPlayerDialogue(9827, "I have my ways.");
				stage = 15;
				break;
		case 15:
			sendNPCDialogue(7888, 9827, "Keep up the great work.");
				stage = 16;
				break;
		case 16:
			sendNPCDialogue(7888, 9827, "You will face more challenges in the future.");
				stage = 17;
				break;
		case 17:
			sendNPCDialogue(7888, 9827, "You should pay Nastroth a visit.");
				stage = 18;
				break;
		case 18:
			    player.getInterfaceManager().closeChatBoxInterface();
            	player.getInterfaceManager().sendInterface(275);
				for (int i = 0; i < 310; i++) {
					player.getPackets().sendIComponentText(275, i, "");
					player.getPackets().sendIComponentText(275, 1, "Quest Complete!</col>");
					player.getPackets().sendIComponentText(275, 13, "You have completed the Skills tutorial!");
					player.getPackets().sendIComponentText(275, 14, "27.5k coins!");
					player.getPackets().sendIComponentText(275, 16, "I should talk to Nasaroth now.");
					}
					//player.getInventory().addItem(24155 ,1);
					player.getInventory().addItem(995 , 27500);
					player.setDoneSkillsTutorial();
					player.falseSkillsTutorial();
                stage = 69;
                break;
		case 69:
			end();
			break;
		case 70:
			end();
			player.getDialogueManager().startDialogue("SimplePlayerMessage", "I should go upstairs in the castle so I can exchange these to the bank.");
			break;
		case -2:
			end();
			break;
	}
}

		@Override
	public void finish() {
		// TODO Auto-generated method stub

	}
}